package com.java.leetcode;

/**
 * @Author ynb
 * 26. 删除有序数组中的重复项
 * @Date 2021/5/27 17:13
 * @Version 1.0
 */
public class LeetCode026 {
    public int removeDuplicates(int[] nums) {
        int index = 1;
        for (int i = 1; i < nums.length; i++){
            if (nums[i] != nums[i - 1]){
                nums[index++] = nums[i];
            }
        }

        return index;
    }

    public static void main(String[] args) {
        LeetCode026 l026 = new LeetCode026();
        int [] nums = {1,1,2};
        System.out.println(l026.removeDuplicates(nums));
        for (int i=0;i<l026.removeDuplicates(nums);i++){
            System.out.print(nums[i]);
        }
    }
}
